/*
 * ChooseCouponHolder.java
 * business
 *
 * Created by ChenTao on 2017/6/22.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.view.View;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.Coupon;
import com.yidiandao.business.ui.widget.listview.ViewHolder;
import com.yidiandao.business.ui.widget.view.RedPacketLayout;

import java.util.List;

/**
 * 选择优惠券
 * <p>
 * Created by ChenTao(chentao7v@gmail.com) on 2017-06-22 17:04
 */
public class ChooseCouponHolder extends ViewHolder {

    public RedPacketLayout mCouponLayout;

    @Override
    protected void initView(View rootView) {
        mCouponLayout = (RedPacketLayout) rootView.findViewById(R.id.red_packet_layout);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_choose_red_packet;
    }

    public void refreshUI(Coupon coupon) {

        mCouponLayout.setType(RedPacketLayout.COUPON);
        mCouponLayout.setCanChoose(true);

        String bonusName = coupon.getBonusName();
        String money = coupon.getMoney() + "";
        List<String> exp = coupon.getExp();

        mCouponLayout.setChecked(coupon.getIsSelected() == 1);
        try {
            mCouponLayout.setRedPacketData(money, bonusName, exp.get(0), exp.get(1), exp.get(2));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
